﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using OpenChart.Entities;

namespace OpenChart.Check
{
    /// <summary>
    /// 生成合法性检查类（AbsChecking）的简单工厂
    /// </summary>
    class CheckingFactory
    {
        /// <summary>
        /// 根据ChartArea实例产生用于检查该ChartArea的AbsChecking子类的实例
        /// </summary>
        /// <param name="chartArea">ChartArea实例</param>
        /// <returns>AbsChecking的子类的实例</returns>
        public static AbsChecking Create(ChartArea chartArea)
        {
            Enums.ChartType type = chartArea.ChartType;
            AbsChecking checking = null;
            switch (type)
            {
                case Enums.ChartType.Line:
                    checking = new LineChartChecking();
                    break;
                case Enums.ChartType.Area:
                    checking = new AreaChartChecking();
                    break;
                case Enums.ChartType.Dot:
                    checking = new DotChartChecking();
                    break;
                case Enums.ChartType.LogarithmLine:
                    checking = new LogarithmLineChartChecking();
                    break;
                case Enums.ChartType.LogarithmArea:
                    checking = new LogarithmAreaChecking();
                    break;
                case Enums.ChartType.LogarithmDot:
                    checking = new LogarithmDotChartChecking();
                    break;
                case Enums.ChartType.Pie:
                    checking = new PieChartChecking();
                    break;
                default:
                    break;
            }
            checking.ChartArea = chartArea;
            return checking;
        }
    }
}
